* Funk, Paul and Philips
* "Point Break: Using Machine Learning to Uncover a Critical Mass in Women’s Representation", Forthcoming at PSRM
*
* Last Updated: 7/19/21
* files created:
* -Figure 2: "QuotaScatterplot.png"
*	-SI Figure 5: "education_OLSresults.pdf"
*	-SI Figure 6: "health_OLSresults.pdf"
*	-SI Figure 7: "defense_OLSresults.pdf"
*	-SI Figure 16: "QuotaScatterplot.png"
* -----------------------------------------------------------------------------

set scheme burd, perm // MAY NEED TO DOWNLOAD. SEARCH FOR "findit burd" IN ORDER TO MATCH GRAPH SCHEMES BELOW
cd "/Users/aqpimac/Dropbox/Kendall-Hannah-Andy/final-replication-june2021"
use funk-paul-philips-replication.dta, clear

* Figure 2:
hist percent_women_Q, xtitle(% of Women in National Parliament) name(percentwomen, replace)
graph export "QuotaScatterplot.png", name(percentwomen) replace 

global variables "percent_women_Q polity2 implementedquota defactothreshold quotastrength1 quotastrength2 quotashock year Agedependencyratioofworki Agricultureforestryandfishi Birthratecrudeper1000peo Employmenttopopulationratio Fertilityratetotalbirthspe Foreigndirectinvestmentneti GDPgrowthannualNYGDPMK GDPpercapitaconstant2010US Importsofgoodsandservices InflationGDPdeflatorannual Laborforceparticipationrate Laborforcefemaleoftotal P Lifeexpectancyatbirthfemale Lifeexpectancyatbirthmale Lifetimeriskofmaternaldeath Maternalmortalityratiomodele PopulationgrowthannualSP Populationdensitypeoplepers PopulationtotalSPPOPTOTL Populationfemaleoftotal Prevalenceofanemiaamongnonp Ruralpopulationoftotalpop Schoolenrollmentprimarygr TradeofGDPNETRDGNFSZS Unemploymenttotaloftotal Unemploymentmaleofmalela"

* For Education
reg percent_education percent_women_Q
est sto OLS_simple
xtreg percent_education percent_women_Q, fe 
est sto OLSFE_simple
reg percent_education l.percent_education percent_women_Q 
est sto OLSLDV_simple
xtreg percent_education percent_women_Q i.year, fe 
est sto OLSFEYR_simple

reg percent_education $variables
est sto OLS
xtreg percent_education $variables, fe 
est sto OLSFE
reg percent_education l.percent_education $variables 
est sto OLSLDV
xtreg percent_education $variables i.year, fe 
est sto OLSFEYR
lab var percent_women_Q "% Women in Legislature"

* Figure 5, SI
coefplot OLS_simple OLSFE_simple OLSLDV_simple OLSFEYR_simple OLS OLSFE OLSLDV OLSFEYR, keep(percent_women_Q) xline(0) title("Education") xtitle("Coefficient Estimate") legend(order(2 "OLS" 4 "OLS-FE" 6 "OLS-LDV" 8 "OLS-2FE" 10 "OLS (full)" 12 "OLS-FE (full)" 14 "OLS-LDV (full)" 16 "OLS-2FE (full)") rows(3))
graph export "education_OLSresults.pdf", as(pdf) replace


* For Health
reg percent_health percent_women_Q
est sto OLS_simple
xtreg percent_health percent_women_Q, fe 
est sto OLSFE_simple
reg percent_health l.percent_health percent_women_Q 
est sto OLSLDV_simple
xtreg percent_health percent_women_Q i.year, fe 
est sto OLSFEYR_simple

reg percent_health $variables
est sto OLS
xtreg percent_health $variables, fe 
est sto OLSFE
reg percent_health l.percent_health $variables 
est sto OLSLDV
xtreg percent_health $variables i.year, fe 
est sto OLSFEYR

* Figure 6, SI
coefplot OLS_simple OLSFE_simple OLSLDV_simple OLSFEYR_simple OLS OLSFE OLSLDV OLSFEYR, keep(percent_women_Q) xline(0) title("Health") xtitle("Coefficient Estimate") legend(order(2 "OLS" 4 "OLS-FE" 6 "OLS-LDV" 8 "OLS-2FE" 10 "OLS (full)" 12 "OLS-FE (full)" 14 "OLS-LDV (full)" 16 "OLS-2FE (full)") rows(3))
graph export "health_OLSresults.pdf", as(pdf) replace



* For Defense
reg percent_military percent_women_Q
est sto OLS_simple
xtreg percent_military percent_women_Q, fe 
est sto OLSFE_simple
reg percent_military l.percent_military percent_women_Q
est sto OLSLDV_simple
xtreg percent_military percent_women_Q i.year, fe 
est sto OLSFEYR_simple

reg percent_military $variables
est sto OLS
xtreg percent_military $variables, fe 
est sto OLSFE
reg percent_military l.percent_military $variables 
est sto OLSLDV
xtreg percent_military $variables i.year, fe 
est sto OLSFEYR

* Figure 7, SI
coefplot OLS_simple OLSFE_simple OLSLDV_simple OLSFEYR_simple OLS OLSFE OLSLDV OLSFEYR, keep(percent_women_Q) xline(0) title("Defense") xtitle("Coefficient Estimate") legend(order(2 "OLS" 4 "OLS-FE" 6 "OLS-LDV" 8 "OLS-2FE" 10 "OLS (full)" 12 "OLS-FE (full)" 14 "OLS-LDV (full)" 16 "OLS-2FE (full)") rows(3))
graph export "defense_OLSresults.pdf", as(pdf) replace

* Figure 16, SI
clonevar temp_pctwomen=percent_women_Q if implementedquota==1 // Making a figure with only countries that have quotas. 
scatter temp_pctwomen percentstatedthreshold, msymbol(oh) ///
	ytitle("Pct. Women Legislators", size(3)) ylabel(0(10)65, angle(90) labsize(3)) ///
	xtitle("Quota Threshold", size(3)) xlabel(0(10)50, labsize(3)) ///
	graphregion(fcolor(white) ilcolor(white) lcolor(white)) ///
	|| function y = x, 	range(0 50) clpat(solid) legend(off) name(q1, replace) 
	graph export "QuotaScatterplot.png", name(q1) replace 
	
